import React, { Component } from 'react'
import './index.scss'
export default class GoodsItem extends Component {

    changeState = (id, flag) => {
        this.props.changeState(id, flag)
    }

    render () {

        let { goods_count, goods_img, goods_name, goods_price, goods_state, id } = (this.props)

        // console.log(this.props)
        return (
            <div className="my-goods-item">
                <div className="left">
                    <div className="custom-control custom-checkbox">
                        <input type="checkbox" className="custom-control-input"
                            checked={goods_state} id={id}
                            onChange={(e) => this.changeState(id, e.target.checked)}
                        />
                        <label className="custom-control-label" htmlFor={id}>
                            <img
                                src={goods_img}
                                alt=""
                            />
                        </label>
                    </div>
                </div>
                <div className="right">
                    <div className="top">{goods_name}</div>
                    <div className="bottom">
                        <span className="price">¥ {goods_price}</span>
                        <span>{goods_count}件</span>
                    </div>
                </div>
            </div>
        )

    }

}